/*
 * @lc app=leetcode.cn id=27 lang=javascript
 *
 * [27] 移除元素
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function (nums, val) {
  let start = 0;
  let end = -1;

  for (const index in nums) {
    if (nums[index] !== val) {
      end = end + 1;
      nums[end] = nums[index];
    }
  }
  return end - start + 1;
};
// @lc code=end
